package com.Runtime;

import java.io.IOException;

/**
 * @Auther: shiquan
 * @Date: 2024/10/24 - 10 - 24 -15:19
 */
public class RuntimeDemo1 {

    public static void main(String[] args) throws IOException {
        //获取Runtime对象
        Runtime r1 = Runtime.getRuntime();
        Runtime r2 = Runtime.getRuntime();
        System.out.println(r1==r2);
        //获取cpu线程数
        System.out.println(Runtime.getRuntime().availableProcessors()/1024/1024); //

        //总内存大小 单位byte
        System.out.println(Runtime.getRuntime().maxMemory()/1024/1024);

        //已经获取的总内存大小
        System.out.println(Runtime.getRuntime().totalMemory()/1024/1024);

        //剩余内存大小
        System.out.println(Runtime.getRuntime().freeMemory()/1024/1024);

        //运行cmd
        System.out.println(Runtime.getRuntime().exec("notepad"));
        System.out.println(Runtime.getRuntime().exec("shutdown-r"));




    }


}
